#include <gtest/gtest.h>

#include "article_main/article_redis_adapter.h"

using namespace std;
using namespace jztzp;

TEST(CommentAdapter, add) {
  ArticleRedisAdapter adapter;

  size_t count = 5;
  int base_article_id = 10000000;
  string content = "hello world";

  for(size_t i = 0; i < count; ++i) {
    EXPECT_TRUE(adapter.SetContent(base_article_id + i, content) == 0);
  }

  for(size_t i = 0; i < count; ++i) {
    string res;
    EXPECT_EQ(adapter.GetContent(base_article_id + i, &res), 0);
    EXPECT_EQ(res, content);
  }

  for(size_t i = 0; i < count; ++i) {
    EXPECT_EQ(adapter.RemoveContent(base_article_id + i), 0);
  }

  for(size_t i = 0; i < count; ++i) {
    string res;
    EXPECT_LT(adapter.GetContent(base_article_id + i, &res), 0);
  }
}

int main(int argc, char* argv[]) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

